#ifndef GESTURERECOGNITION_H
#define GESTURERECOGNITION_H

//OS Specific includes
#ifdef _WIN32
#include <cv.h>
#include <highgui.h>
#else
#include <opencv/cv.h>
#include <opencv/highgui.h>
#endif

//generic includes
#include <QObject>
#include <QImage>
#include <QColor>
#include <QDebug>


class GestureRecognition : public QObject
{
Q_OBJECT

private:
    //frame procesing
    QImage recognitionArea;
    int startX, startY;
    int width, height;
    int id;
    unsigned long pixelDif;
    //change this to dynamic memory later
    unsigned long lastPixelDiffs [50];

    //gesture recognition
    int framesToSkip;
    unsigned int minFramesProcessed;
    unsigned int currentFramesProcessed;
    unsigned int averagePixelDif;
    double sensitivity;
    unsigned int consecutiveDetections;

public:
    /** Default constructor
      *
      */
    explicit GestureRecognition(QObject *parent = 0);
    /** Constructor for GestureRecognition class.
      * Sets up which area of image will be monitored for movement.
      */
    explicit GestureRecognition(int idNum, int startXVal, int startYVal, int widthVal, int heightVal, QObject *parent = 0);

    /** Read in the next frame and update our recognition area, keeping track of the iamge change.
      */
    void nextFrame(IplImage* image);

    /** Analyses the last frames in order to check for a gesture.
      *
      */
    void checkForGesture();

    /**
      * Accessor method
      */
    int getX();

    /**
      * Accessor method
      */
    int getY();

    /**
      * Accessor method
      */
    int getWidth();

    /**
      * Accessor method
      */
    int getHeight();

    /** Sets the gesture recognition sensitivity. Recommended range is 1.2 to 5, where 1.2 is most sensitive.
      */
    void setSensitivity(double sens);
    double getSensitivity();


signals:
    //the gesture emitted signal
    void gestureDetected(int id);    


};

#endif // GESTURERECOGNITION_H
